<?php

namespace App\Controllers;

use \Core\View;

/**
* Home controller
*
* PHP version 5.6
*/
class Home extends \Core\Controller
{
	/**
	* Before filter
	*
	* @return void
	*/
	protected function before()
	{
		//echo "(before)";
        //return true;  // false to abort.
	}
	
	/**
	* After filter
	*
	* @return void
	*/
	protected function after()
	{
		//echo "(after)";
	}
	
	/**
	* Show the index page
	*
	* @return void
	*/
	public function indexAction()
	{
		//echo 'Hello from the index action in the Home controller!';
		
		/*View::render('Home' . DS . 'index.php', [
			"name" => "Laura",
			"colours" => ["red", "green", "blue"]
		]);*/
		
		// View::renderTemplate('Home' . DS . 'index.html', [
		// 	"name" => "Laura",
		// 	"colours" => ["red", "green", "blue"]
        // ]);
        
        $this->showRouteParams();
    }
    
    /**
    * Show route parameters
    *
    * @return void
    */
    public function showRouteParams()
    {
		echo "<pre>";
		print_r($_SERVER);
		echo "</pre>";
		echo '<p>Route parameters: <pre>' . htmlspecialchars(print_r($this->route_params, true)) . '</pre></p>';
		
		echo '<p>age: ' . $_GET['age'] . '</p>';
		echo '<p>female: ' . $_GET['female'] . '</p>';

		echo "<pre>";
		print_r($_GET);
		echo "</pre>";

		echo "<p>DS: " . DS . "<p/>";
		echo "<p>ROOT: " . ROOT . "<p/>";
		echo "<p>WWWROOT: " . WWWROOT . "<p/>";
    }
}
